﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Kepp.Extend.Class
{
    /// <summary>
    /// 容器类
    /// </summary>
    public class TitleClass: MyClass
    {
        /// <summary>
        /// 编号
        /// </summary>
        public int ID { get; set; }
        /// <summary>
        /// 标题
        /// </summary>
        public string title { get; set; }

        /// <summary>
        /// 简介
        /// </summary>
        public string ps { get; set; } = "";

        /// <summary>
        /// 指定方法
        /// </summary>
        public string fun { get; set; }

        /// <summary>
        /// 子类
        /// </summary>
        public List<TitleClass> Child { get; set; }

        /// <summary>
        /// 输出
        /// </summary>
        /// <returns></returns>
        public TitleClass Output() 
        {
            this.Child.ForEach(x => Console.WriteLine($"{this.Child.IndexOf(x) + 1}.{x.title}"));
            return this;
        }


        /// <summary>
        /// 详细输出
        /// </summary>
        /// <returns></returns>
        public TitleClass Res() {
            Console.WriteLine($"{this.title}\n--- 简介 ---\n {this.Feng(this.ps)}\n---        ---");
            return this;
        }



        /// <summary>
        /// 分割说明
        /// </summary>
        /// <returns></returns>
        public string Feng(string e)
        {
            int number = 30;
            while (e.Length>number)
            {
                e=e.Insert(number, "\n ");
                number += 30;
            }
            return e;
        }

    }
}
